<?php

	/**
	 * File : list_view_column.php
	 * Description : Définition et fonctions des colones du composant list_view
	 * Date : 07.08.2012 15:09:13
	 * 
	 * This file is part of Phenix.  Phenix is free software: you can
	 * redistribute it and/or modify it under the terms of the GNU General Public
	 * License as published by the Free Software Foundation, version 2.
	 *
	 * This program is distributed in the hope that it will be useful, but WITHOUT
	 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
	 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
	 * details.
	 *
	 * You should have received a copy of the GNU General Public License along with
	 * this program; if not, write to the Free Software Foundation, Inc., 51
	 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
	 *
	 * Nils Schaetti <n.schaetti@gmail.com>
	**/

	/*
	 * Différentes types de colonnes
	 */
	define('COLUMN_TYPE_TEXT',0);
	define('COLUMN_TYPE_IMAGE',1);
	define('COLUMN_TYPE_CHECKBOX',2);

	/*
	 * Classe représentant une colonne
	 */
	class ktkListViewColumn
	{
	
		/***********************
		 * Propriétés
		 ***********************/
		 
		/*
		 * Type de colonne
		 */
		private $Type = COLUMN_TYPE_TEXT;
	
		/*
		 * Nom de la colonne
		 */
		private $Name = '';
		
		/*
		 * Couleur du texte de l'entête
		 */
		private $Color = '';
		
		/**
		 * ID de la ligne
		 */
		private $Id;
	
		/***********************
		 * Fonctions
		 ***********************/
		 
		/*
		 * Construteur
		 */
		public function ktkListViewColumn($name, $id, $type)
		{
			$this->Id = $id;
			$this->Name = $name;
			$this->Type = $type;
		}
		 
		/*
		 * Retourne le code HTML de la colonne
		 */
		public function getCode()
		{
			// Le code
			$code = '<td class="@@_TYPE_@@" id="'.$this->Id.'">@@_CONTENT_@@</td>';
		
			// Nom
			$content = $this->Name;
		
			// Selon le type de colonne
			switch($this->Type)
			{
				case COLUMN_TYPE_TEXT:
					$id = 'ktkListViewTdHeader';
					break;
				case COLUMN_TYPE_IMAGE:
					$id = 'ktkListViewTdSmall';
					break;
				case COLUMN_TYPE_CHECKBOX:
					$id = 'ktkListViewTdSmall';
					break;
			}
			
			// Remplacement
			$code = str_replace('@@_TYPE_@@', $id, $code);
			$code = str_replace('@@_CONTENT_@@', $content, $code);
			
			return $code;
		}
		
		/*
		 * Retourne le type de la colonne
		 */
		public function getType() { return $this->Type; }
		
		/**
		 * Retourne l'id de la colonne
		 */
		public function getId() { return $this->Id;}
	
	}

?>
